- main_toolbar do |t|
  = t.edit resource

= janus do |j|
  - j.face :list do
    = cobbles do |c|
      - c.cobble :general_informations do
        = infos do
          - unless resource.pacage_number.blank?
            .med-info
              %span.title= CapStatement.human_attribute_name(:pacage_number)
              %span.value= resource.pacage_number
          .med-info
            %span.title= CapStatement.human_attribute_name(:campaign)
            %span.value= resource.campaign.name
          - unless resource.farm_name.blank?
            .med-info
              %span.title= CapStatement.human_attribute_name(:farm_name)
              %span.value= resource.farm_name
          - unless resource.siret_number.blank?
            .med-info
              %span.title= CapStatement.human_attribute_name(:siret_number)
              %span.value= resource.siret_number
          - if resource.declarant
            .med-info
              %span.title= CapStatement.human_attribute_name(:declarant)
              %span.value= resource.declarant.full_name
          .med-info
            %span.title= :net_surface_area.tl
            %span.value= resource.human_net_surface_area
          .med-info
            %span.title= :number_of_cap_islets.tl
            %span.value= resource.cap_islets.count
          .med-info
            %span.title= :number_of_cap_land_parcels.tl
            %span.value= resource.cap_land_parcels.count
      -# c.cobble(:cap_islets) do
        #= cobble_list(:cap_islets)
      - c.cobble(:cap_land_parcels) do
        = cobble_list(:cap_land_parcels)

  - if resource.cap_land_parcels.any?
    - j.face :map do
      :ruby
        land_parcels = resource.cap_land_parcels.collect do |p|
          next unless p.shape

          popup_content = []
          popup_content << {label: CapLandParcel.human_attribute_name(:net_surface_area), value: p.human_shape_area}
          popup_content << render('popup', plant: p)

          { name: "#{p.land_parcel_number} - #{p.cap_islet.islet_number}", shape: p.shape, main_crop_code: p.main_crop_code, popup: {header: true, content: popup_content} }
        end

        islets = resource.cap_islets.collect do |p|
          next unless p.shape
          popup_content = []
          popup_content << {label: CapIslet.human_attribute_name(:net_surface_area), value: p.human_shape_area}
          popup_content << render('popup', plant: p)

          {name: p.islet_number, shape: p.shape, popup: {header: true, content: popup_content} }
        end

      = visualization({box: {height: "100%"}}, class: 'map-fullwidth') do |v|
        - v.serie :land_parcels, land_parcels
        - v.serie :islets, islets
        - v.simple :cap_islets, :islets
        - v.categories :main_crop_code, :land_parcels
        - v.control :zoom
        - v.control :scale
        - v.control :fullscreen
        - v.control :layer_selector
